use getset::{Getters, MutGetters, Setters};

///服务启动配置
#[derive(
    Debug,
    PartialEq,
    serde::Serialize,
    serde::Deserialize,
    Clone,
    Getters,
    Setters,
    MutGetters,
    Default,
)]
#[getset(get_mut = "pub", get = "pub", set = "pub")]
pub struct ApplicationConfig {
    pub base_url: String,
}

impl ApplicationConfig {
    pub fn from_toml(toml_data: &str) -> Self {
        let config = match toml::from_str(toml_data) {
            Ok(e) => e,
            Err(e) => panic!("{}", e),
        };
        config
    }
}

use clap::Parser;
use serde::Serialize;

#[derive(Debug, Clone, Parser, Serialize)]
#[clap(version)]
pub struct Opt {
    #[clap(long, env = "config", default_value = "")]
    pub config_path: String,
    #[clap(long, env = "print_log", default_value = "false")]
    pub print_log: bool,
}
